import fetch from '../../utils/request';
import axios from 'axios'
import qs from 'qs'
// ---------------------------目录分类  --------------------/
export async function getTreeData() {
  let params = {}
  return fetch({url: '/apc/api/catalogue/getTreeData', method: 'get',params})
}
//获得某一目录下下一个Number
export async function getNumber(params) {
  return fetch({url: '/apc/api/catalogue/getNumber', method: 'get', params})
}

//删除目录记录
export async function deleteCategory(params) {
  return fetch({url: '/apc/api/catalogue/deleteByNumber', method: 'get', params})
}

export async function getAllCategoryInfos(params) {
  return fetch({url: '/apc/api/catalogue/allCatalogueInfos', method: 'get', params})
}

export  async function insertNewCategory(params) {
  return fetch({url: '/apc/api/catalogue/insertNewCatalogueType', method: 'post', params})
}

//根据编码修改记录
export async function updateCatalogue(params) {
  return fetch({ url: '/apc/api/catalogue/updataCatalogueInfoByPreKey', method: 'post', params})
}

//--------------------------目录登记---------------------/
export async function findExaming(params) {
  return fetch({url: '/apc/api/resourceInfo/findExamining', method: 'get', params})
}
export async function findNoPost(params) {
  return fetch({url: '/apc/api/resourceInfo/findNoPost', method: 'get', params})
}
export async function findFailure(params) {
  return fetch({url: '/apc/api/resourceInfo/findFailure', method: 'get', params})
}

//根据新建前根据目录代码查询资源名称，提供方名称及新资源id
export async function getNewResBaseInfo(params) {
  return fetch({url: '/apc//api/resourceInfo/getSomeInfo', method: 'get', params})
}

//根据部门级别查询已退回
export async function findFailureByNumber(params) {
  return fetch({url: '/apc/api/resourceInfo/findFailureByNumber', method: 'get', params})
}
export async function findNoPostByNumber(params) {
  return fetch({url: '/apc/api/resourceInfo/findNoPostByNumber', method: 'get', params})
}
export async function findExamingByNumber(params) {
  return fetch({url: '/apc/api/resourceInfo/findExaminingByNumber', method: 'get', params})
}
//查看所有元数据类型

export async function getAllMetaDataTypes(params) {
  return fetch({url: '/apc/api/metaType/findAllNoPage', method: 'get', params})
}
//按元数据类型查看所有
export async function getAllMetaData(params) {
  return fetch({url: '/apc/api/metaInfo/findAllNoPage', method: 'post', params})
}
//按元数据名称查询
export async function getMetaDataTypeByName(params) {
  return fetch({url: '/apc/api/metaType/findByFuzzyName', method: 'get', params})
}

//目录登记第一页内容保存
export async function saveNewCateRegFriPage(params) {
  return fetch({url: '/apc/api/resourceInfo/insertNewResourceInfo', method: 'post', params})
}
export async function saveNewCateRegSecPage(params) {
  let newParam = qs.stringify(params, {arrayFormat: 'repeat'})
  // axios.post('/apc/api/resourceInfo/addRelations', newParam).then(res => {})
  console.log('params', params)
  return fetch({url: '/apc/api/resourceInfo/addRelations', method: 'post', params, trans: true })
}
//编辑及查看信息获取
export async function getResourceInfo(params) {
  return fetch({url: '/apc/api/resourceInfo/getResourceInfoByResourceId', method: 'get', params})
}
export async function getResourceTableInfo(params) {
  return fetch({url: '/apc/api/resourceInfo/getMetaDataInfosByesourceId', method: 'get', params})
}

//报送
export async function postResource(params) {
  return fetch({url: '/apc//api/resourceInfo/resourceInfoPost', method: 'get', params})
}
//重新报送
export async function repostResource(params) {
  return fetch({url: '/apc/api/resourceInfo/rePost', method: 'get', params})
}

export async function deleteResourceById(params) {
  return fetch({url: '/apc/api/resourceInfo/deleteResourceInfoByPreKey', method: 'get', params})
}

//---------------------------目录发布---------------------- /
export async function findUnpublished(params) {
  return fetch({url: '/apc/api/release/findUnpublished', method: 'get', params})
}

export async function findPublished(params) {
  return fetch({url: '/apc/api/release/findPublished', method: 'get', params})
}
//删除未发布
export async function deleteUbpublish(params) {
  return fetch({url: '/apc/api/release/delete', method: 'get', params})
}
//发布
export async function publishResource(params) {
  return fetch({url: '/apc/api/release/publish', method: 'get', params})
}


//------------------------------目录审核----------------/
export async function findAuditExaming(params) {//待审核
  return fetch({url: '/apc/api/examine/findExamining', method: 'get', params})
}

export async function findAuditPass(params) {//已通过
  return fetch({url: '/apc/api/examine/findPass', method: 'get', params})
}
export async function findAuditFailure(params) {//未通过
  return fetch({url: '/apc/api/examine/findFailure', method: 'get', params})
}
export async function passAudit(params) {//审核通过
  return fetch({url: '/apc/api/examine/pass', method: 'get', params})
}

export async function unpassAudit(params) {
  return fetch({url: '/apc/api/examine/failure', method: 'get', params})
}

export async function getUntrendReason(params) {
  return fetch({url: '/apc/api/examine/getExplanation', method: 'get', params})
}
//-----------------------资源链接----------------------- /
export function findLoaded(params) {
  return fetch({url: '/apc/api/load/findLoaded', method: 'get', params})
}






// 资源申请
export function resource(params) {
  return fetch({url: '/apc/api/load/findUnLoaded', method: 'get', params})
}
//测试登录
export function login(params) {
  // return fetch({url: '/api/login', method: 'post', params})
  return fetch({url: '/apc/api/login', method: 'post', params})
}